home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / dlbox_2 / inter.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-27  |  7.1 KB  |  265 lines

  1. #if !defined(__interface_h)
  2. #define __interface_h
  3. #include<graphics.h>
  4. #include "mouse.h"
  5.  
  6. enum THINGS {BUTTON, FIELD, SLIDE, RADIO,CHECKBOX,PIC};
  7. enum INPUT_TYPE {KEYBOARD, MOUSE,NOTHING};
  8. enum FIELDTYPE {NUMBER, TEXT};
  9. enum BUTTON_STATUS {UNPRESSED, PRESSED};
  10. enum CHECKBOX_STATUS {UNCHECKED, CHECKED};
  11.  
  12. const int DELAYTIME=200;   //milliseconds in delay of button press
  13. const int MAXSTRINGLEN=127;
  14. const int MAXLINES=50;
  15. const int MAXLBOXES=50;
  16. const int MAXBUTTONS=30;
  17. const int MAXPICS_S=50;
  18. const int MAXPICS=50;
  19. const int MAXCHECKBOXES=20;
  20. const int MAXFIELDS=10;
  21. const int MAXSLIDES=20;
  22. const int MAXTITLES=30;
  23. const int MAXBARS=1;
  24. const int MAXBOXES=1;
  25. const int MAXRADIOS=10;
  26. const int HEIGHT=20;       //height of buttons
  27. const int FIELDHEIGHT=15;
  28.  
  29. typedef struct i_face { THINGS type;
  30.             int code; //used to ID the corresponding thing
  31.                   //better be unique
  32.             char * return_text;
  33.             int return_value;
  34.             BUTTON_STATUS button_status;
  35.             CHECKBOX_STATUS checkbox_status;
  36.             struct i_face * next;} return_type;
  37.  
  38. typedef struct {int finished;
  39.         INPUT_TYPE transfer;} control_struct;
  40.  
  41. typedef struct _zones { int x1,y1,x2,y2; //coordinates of box
  42.                THINGS type;
  43.                int number;
  44.                struct _zones * next;} zone_type;
  45.  
  46. typedef struct { int x,y;
  47.          char k1,k2;
  48.          INPUT_TYPE type;
  49.            } input_struct;
  50.  
  51. typedef struct {char * text;
  52.         int x;int y;
  53.         int code; int width;
  54.         int x1;int y1;int x2;int y2;
  55.         return_type * return_code;
  56.         } button_struct;
  57.  
  58. typedef struct {
  59.           int x;int y;
  60.           int width,height;
  61.           int code;
  62.           void far *pic;
  63.           return_type * return_code;
  64.         } pic_struct;
  65.  
  66. typedef struct {
  67.           int x;int y;
  68.           void far *pic;
  69.         } pic_s_struct;
  70.  
  71. typedef struct {char * text;
  72.         int x;int y;
  73.         int code;
  74.         return_type * return_code;
  75.         } checkbox_struct;
  76.  
  77. typedef struct {char * deftext;
  78.         int x; int y;
  79.         int width; int code;
  80.         return_type * return_code;
  81.         char ret[MAXSTRINGLEN+1];
  82.         FIELDTYPE ftype;
  83.         } field_struct;
  84.  
  85. typedef struct {int defvalue;
  86.         int x; int y;
  87.         int code;
  88.         return_type * return_code;
  89.         } slide_struct;
  90.  
  91. typedef struct {char * text;
  92.         int x; int y;
  93.         int color;
  94.         int size; int font;
  95.         int horiz_just;int vert_just;
  96.         } title_struct;
  97.  
  98. typedef struct {char * text;
  99.         int x;int y;
  100.         int code;
  101.         int radio_id;
  102.         return_type * return_code;
  103.         } radio_struct;
  104.  
  105. typedef struct {int x; int y;
  106.         int width; int height;
  107.         int color; int border;
  108.         void far *buf;
  109.         } box_struct;
  110.  
  111. typedef struct {int x1; int y1;
  112.         int x2; int y2;
  113.         int color;
  114.         } line_struct;
  115.  
  116. typedef struct {int x1; int y1;
  117.         int x2; int y2;
  118.         int color;
  119.         } lbox_struct;
  120.  
  121. typedef struct {char *s;
  122.         int color;
  123.         int font;
  124.         int font_size;
  125.         int font_color;
  126.         int height;
  127.         } bar_struct;
  128.  
  129. typedef struct {pic_struct pics[MAXPICS];
  130.         pic_s_struct pics_s[MAXPICS_S];
  131.         line_struct lines[MAXLINES];
  132.         lbox_struct lboxes[MAXLBOXES];
  133.         button_struct buttons[MAXBUTTONS];
  134.         field_struct fields[MAXFIELDS];
  135.         slide_struct slides[MAXSLIDES];
  136.         title_struct titles[MAXTITLES];
  137.         box_struct boxes[MAXBOXES];
  138.         bar_struct bars[MAXBARS];
  139.         checkbox_struct checkboxes[MAXCHECKBOXES];
  140.         radio_struct radios[MAXRADIOS];
  141.         int numpics, numbuttons, numfields, numslides, numtitles,
  142.           numboxes, numradios,numcheckboxes, numbars, numlines,
  143.           numlboxes, numpics_s;
  144.         int dont_erase;
  145.         int mouse_placed;
  146.         int mouse_locked;
  147.         int mouse_x,mouse_y;
  148.         control_struct control;
  149.         int charwidth;
  150.         int boxx,boxy;
  151.         return_type * return_head;
  152.         zone_type * zones;
  153.         zone_type * zones_head;
  154.         zone_type * curzone;
  155.  
  156.         int disk_writes;
  157.         char file_name[128];
  158.         } interface_struct;
  159.  
  160. class interface_class {
  161.     interface_struct interface;
  162.     int slideheight,slidewidth;
  163.     void error(char *);
  164.     void operate_items();
  165.     zone_type * find_new_zone();
  166.     void setup_mouse_zone(int, int, int, int,
  167.               THINGS ,int);
  168.     int  inzone(int, int, zone_type*);
  169.     return_type * add_setup_return();
  170.     return_type * setup_return(int, int);
  171.     return_type * setup_return(int, char*,
  172.                    char*, FIELDTYPE);
  173.     return_type * setup_return(int, BUTTON_STATUS);
  174.     return_type * setup_return(int, CHECKBOX_STATUS);
  175.     void dopic(int);
  176.     void docheckbox(int);
  177.     void doradio(int);
  178.     void dobutton(int);
  179.     void doslide(int);
  180.     void dofield(int);
  181.     void highlight_slide(int);
  182.     void highlight_slide_left(int);
  183.     void highlight_slide_right(int);
  184.     void update_slide(int);
  185.     void highlight_radio(int);
  186.     void unhighlight_radio(int);
  187.     void uncheck_others(int,int);
  188.     void clear_radio(int);
  189.     void check_radio(int);
  190.     void toggle_radio(int);
  191.     void highlight_checkbox(int);
  192.     void unhighlight_checkbox(int);
  193.     void clear_checkbox(int);
  194.     void check_checkbox(int);
  195.     void toggle_checkbox(int);
  196.     void highlight_pic(int);
  197.     void unhighlight_pic(int);
  198.     void highlight_button(int);
  199.     void unhighlight_button(int);
  200.     void do_save_image(int,int,int,int);
  201.     void lock_mouse();
  202.     void press_pic(int);
  203.     void press_button(int);
  204.     void draw_pics();
  205.     void draw_pics_s();
  206.     void draw_buttons();
  207.     void draw_checkboxes();
  208.     void draw_bars();
  209.     void draw_lboxes();
  210.     void draw_lines();
  211.     void draw_boxes();
  212.     void draw_radios();
  213.     void erase_boxes();
  214.     void draw_titles();
  215.     void draw_slides();
  216.     void draw_items();
  217.     void erase_items();
  218.     void reset_input();
  219.     void getinput(input_struct*);
  220.     void draw_fields();
  221.     void draw_cursor(int);
  222.     void hide_cursor(int);
  223.     void highlight_field(int);
  224.     void unhighlight_field(int);
  225.     void update_field(int);
  226.     void free_zone_list();
  227.     void free_return_list();
  228.     return_type * find_item(int);
  229.   public:
  230.     mouse_class mouse;
  231.     interface_class();
  232.     void disk_writes_on(char *);
  233.     void lock_mouse_in_box();
  234.     void place_mouse(int,int);
  235.     void set_dont_erase();
  236.     void clear();
  237.     void set_mouse_bounds(int,int,int,int);
  238.     void addline(int,int,int,int,int);
  239.     void addlbox(int,int,int,int,int);
  240.     void addbar(char*,int color=BLUE,int font=DEFAULT_FONT,int font_size=1,int font_color=15);
  241.     void addcheckbox(char*,int, int, int,CHECKBOX_STATUS);
  242.     void addradio(char*,int, int, int,int,CHECKBOX_STATUS);
  243.     void addpic_b(int x, int y, int width, int height, int code,void far *p);
  244.     void addpic_s(int x, int y, void far *p);
  245.     void addbutton(char*,int, int, int, int width=60);
  246.     void addfield(char*, int, int, int, int,
  247.            FIELDTYPE);
  248.     void addslide(int, int, int, int);
  249.     void addtitle(char *, int, int, int color=DARKGRAY,
  250.           int size=1, int font=DEFAULT_FONT,int horiz_just=LEFT_TEXT,
  251.           int vert_just=TOP_TEXT);
  252.     void addbox(int, int, int, int,
  253.         int color=WHITE, int border=LIGHTGRAY);
  254.     void dodialog();
  255.     
  256.     CHECKBOX_STATUS get_checkbox_info(int);
  257.     CHECKBOX_STATUS get_radio_info(int);
  258.     BUTTON_STATUS get_button_info(int);
  259.     BUTTON_STATUS get_pic_info(int);
  260.     char * get_text_field_info(int);
  261.     int get_number_field_info(int);
  262.     int get_slide_info(int);
  263.     };
  264. #endif
  265.